use serde::Serialize;
use utoipa::ToSchema;

use crate::domain::entity::User;

#[derive(Clone, Debug, Default, Serialize, ToSchema)]
#[schema(title = "UserDetailVO", description = "用户详情信息")]
pub struct UserDetailVO {
    #[schema(example = "1")]
    pub id: u64,
    #[schema(example = "张三", nullable = false, min_length = 2, max_length = 20)]
    pub name: String,
    #[schema(example = "<EMAIL>", nullable = false, min_length = 6, max_length = 50)]
    pub email: String,
}

impl From<User> for UserDetailVO {
    fn from(user: User) -> Self {
        UserDetailVO {
            id: user.id,
            name: user.name.to_owned(),
            email: user.email.to_owned(),
        }
    }
}
